
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>2、继承静态和重写 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>2、继承静态和重写 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">在Java中，`static`关键字的核心作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`static`关键字用于定义类级别的成员（如变量、方法、代码块），使其与类本身相关联，而不是与类的某个具体对象相关联。所有对象共享同一份静态成员的副本。</div>
          </div>
          <div class="card-source">来源: static关键子</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">静态代码块（static block）在何时执行，且会执行多少次？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">静态代码块在类加载时执行，并且在整个程序生命周期中仅执行一次。它通常用于执行静态变量的初始化或静态资源的加载。</div>
          </div>
          <div class="card-source">来源: static关键子</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">为什么静态方法不能直接访问非静态成员？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为静态方法属于类，它们在对象创建之前就已经存在。而非静态成员是与对象实例相关联的，必须在对象创建之后才能访问，因此静态方法无法直接访问它们。</div>
          </div>
          <div class="card-source">来源: static关键子</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Java继承中，`extends`和`super`关键字分别扮演什么角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`extends`关键字用于定义子类并指定其父类，从而实现继承。`super`关键字用于在子类中引用父类的成员（变量和方法）或调用父类的构造方法。</div>
          </div>
          <div class="card-source">来源: 继承</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">概念</div>
          <div class="card-question">什么是方法重写（Method Overriding）？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">概念</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">方法重写是指子类可以定义一个与父类具有相同方法签名（方法名、参数列表）的方法，以改变或扩展其行为。这是实现多态性的关键机制之一。</div>
          </div>
          <div class="card-source">来源: 继承</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Java中的 `Object` 类在类继承体系中处于什么地位？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`Object` 类是所有Java类的根类，它位于Java类层次结构的顶端。所有其他类都直接或间接地继承了`Object`类中的通用方法。</div>
          </div>
          <div class="card-source">来源: Object类</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">`final`关键字可以修饰哪三种主要的程序元素，并分别起到什么作用？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">1. 修饰类：表示该类不可被继承。2. 修饰方法：表示该方法不可被子类重写（覆盖）。3. 修饰变量：表示该变量为常量，其值在初始化后不可更改。</div>
          </div>
          <div class="card-source">来源: Final关键子</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当`final`关键字修饰一个对象引用时，它具体限制了什么？对象本身的内容是否可以改变？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当`final`修饰对象引用时，它限制的是该引用不能再指向其他对象。然而，被该引用指向的对象本身的内容（内部状态）是可以改变的。</div>
          </div>
          <div class="card-source">来源: Final关键子</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">为什么在重写`equals()`方法时，通常也需要重写`hashCode()`方法？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">为了保证一致性。如果重写了`equals()`方法来定义对象的相等性，那么也必须重写`hashCode()`方法，以确保根据`equals()`方法相等的两个对象返回相同的哈希码值。这对于哈希表等数据结构的正确运行至关重要。</div>
          </div>
          <div class="card-source">来源: Object类</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
